home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 July / EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso / earcd / grafica / ghostscript / 5.10 / data / viewcmyk.ps < prev    next >
Text File  |  1997-06-11  |  2KB  |  69 lines

  1. %    Copyright (C) 1996, 1997 Aladdin Enterprises.  All rights reserved.
  2. %
  3. % This file is part of Ghostscript.
  4. %
  5. % Ghostscript is distributed in the hope that it will be useful, but
  6. % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. % to anyone for the consequences of using it or for whether it serves any
  8. % particular purpose or works at all, unless he says so in writing.  Refer
  9. % to the Ghostscript General Public License for full details.
  10. %
  11. % Everyone is granted permission to copy, modify and redistribute
  12. % Ghostscript, but only under the conditions described in the Ghostscript
  13. % General Public License.  A copy of this license is supposed to have been
  14. % given to you along with Ghostscript so you can know your rights and
  15. % responsibilities.  It should be in a file named COPYING.  Among other
  16. % things, the copyright notice and this notice must be preserved on all
  17. % copies.
  18.  
  19. % viewcmyk.ps
  20. % Display a raw CMYK file.
  21. % Requires the colorimage operator.
  22. % If SCALE is defined, maps input pixels to output pixels with that scale;
  23. % if SCALE is undefined, scales the image to fit the page.
  24. % If BITS is defined, it is the number of bits per sample (1,2,4,8,12);
  25. % if BITS is undefined, its default value is 1.
  26.  
  27. /viewcmyk            % <filename> <width> viewcmyk -
  28.  { 20 dict begin
  29.    /w exch def
  30.    /fname exch def
  31.    /bpc /BITS where { pop BITS } { 1 } ifelse def
  32.    /f fname (r) file def
  33.    mark fname status pop pop pop /flen exch def cleartomark
  34.    /h flen w bpc 4 mul mul 7 add 8 idiv idiv def
  35.    (Dimensions: ) print [w h] == flush
  36.         % Set up scaling.
  37.    /SCALE where
  38.     { pop
  39.     % Map pixels SCALE-for-1.  Assume orthogonal transformation.
  40.       w 1 0 dtransform add abs div SCALE mul
  41.       h 0 1 dtransform add abs div SCALE mul
  42.     }
  43.     {    % Scale the image (uniformly) to fit the page.
  44.       clippath pathbbox pop pop translate
  45.       pathbbox 4 2 roll pop pop
  46.       h div w mul min dup
  47.     }
  48.    ifelse scale
  49.    w h bpc [w 0 0 h neg 0 h] f false 4 colorimage
  50.    showpage
  51.    f closefile
  52.    end
  53.  } bind def
  54.  
  55. % If the program was invoked from the command line, run it now.
  56. [ shellarguments
  57.  { counttomark 2 eq
  58.     { cvi viewcmyk
  59.     }
  60.     { cleartomark
  61.       (Usage: gs -- viewcmyk.ps filename.cmyk width\n) print
  62.       ( e.g.: gs -- viewcmyk.ps my.cmyk 2550\n) print flush
  63.     }
  64.    ifelse
  65.  }
  66.  { pop
  67.  }
  68. ifelse
  69.